@extends('layouts.base')

@section('title', '主板类型')

@section('admin-style')
    <link rel="stylesheet" href="{{ asset('/assets/plugins/dropify/dist/css/dropify.min.css') }}">
    <link href="{{ asset('/assets/plugins/clockpicker/dist/jquery-clockpicker.min.css') }}" rel="stylesheet">
    <style type="text/css">
        .bg-muted {
            background: #99abb4
        }
        .text-color {
            color:  #FFFFFF;
        }
    </style>
@stop

@section('content')
<div class="container-fluid">
    <!-- ============================================================== -->
    <!-- Bread crumb and right sidebar toggle -->
    <!-- ============================================================== -->
    <div class="row page-titles">
        <div class="col-md-5 align-self-center">
            <h3 class="text-themecolor">货道模板</h3>
        </div>
        <div class="col-md-7 align-self-center">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="javascript:void(0)">首页</a></li>
                <li class="breadcrumb-item">货道模板管理</li>
                <li class="breadcrumb-item active">货道模板编辑</li>
            </ol>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header bg-success">
                    <h4 class="m-b-0 text-white">添加配置</h4>
                </div>
                <div class="card-body"></div>
                <form class="needs-validation" method="post" action="{{ route('admin.freightWayDemos.update', $freightWayDemo->id) }}" novalidate>  
                    @csrf
                    @method('PUT')
                    <div class="card-body">
                        <div class="form-body">
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">货道名称：</label>
                                <div class="col-md-7">
                                    <input type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" placeholder="名称" value="{{ old('name', $freightWayDemo->name) }}" required>
                                    @if ($errors->has('name'))
                                        <span class="invalid-feedback" role="alert">
                                            <strong>{{ $errors->first('name') }}</strong>
                                        </span>
                                    @endif
                                    <div class="invalid-feedback">
                                       请填写名称
                                    </div>                                 
                                </div>
                            </div>  
                            <div class="form-group row">
                                <label class="control-label text-right col-md-2" for="">货道数：</label>
                                <div class="col-md-7">
                                    <input readonly type="number" class="form-control{{ $errors->has('freight_num') ? ' is-invalid' : '' }}" id="" name="freight_num" placeholder="货道数" value="{{ old('freight_num', $freightWayDemo->freight_num) }}" required>
                                    @if ($errors->has('freight_num'))
                                        <span class="invalid-feedback" role="alert">
                                            <strong>{{ $errors->first('freight_num') }}</strong>
                                        </span>
                                    @endif
                                    <div class="invalid-feedback">
                                       请填写货道数
                                    </div>
                                </div>
                            </div> 
                            {{-- <div class="form-group row">
                                <label for="example-month-input" class="col-md-2 text-right col-form-label">主板类型: </label>
                                <div class="col-md-7">
                                    <select name="mainborad_id" class="custom-select" required>
                                        <option value>请选择主板</option>
                                        @foreach($mainborads as $mainborad)
                                            <option @if(optional($freightWayDemo->mainborad)->id == $mainborad->id) selected @endif value="{{ $mainborad->id }}">{{ $mainborad->name }}</option>
                                        @endforeach
                                    </select>
                                    @if ($errors->has('mainborad_id'))
                                        <span class="invalid-feedback" role="alert">
                                            <strong>{{ $errors->first('mainborad_id') }}</strong>
                                        </span>
                                    @endif
                                    <div class="invalid-feedback">
                                       请选择主板类型
                                    </div>
                                </div>
                            </div> --}}
                        </div>
                        <div class="form-actions">
                            <div class="row">
                                <div class="col-md-8">
                                    <div class="row">
                                        <div class="offset-sm-3 col-md-9">
                                            <button type="submit" class="btn btn-success"> <i class="fa fa-check"></i> 提交</button>
                                            <a href="{{ route('admin.freightWayDemos.index') }}"><button type="button" class="btn btn-danger"><i class=" fas fa-times"></i> 取消</button></a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>                    
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@stop

@section('admin-js')

<!--Custom JavaScript -->
<script src="{{ asset('assets/js/validation.js') }}"></script>
<!-- jQuery file upload -->
<script src="{{ asset('assets/plugins/dropify/dist/js/dropify.min.js') }}"></script>

<script>
//For validation with custom styles
    (function() {
      'use strict';
      window.addEventListener('load', function() {
        // Fetch all the forms we want to apply custom Bootstrap validation styles to
        var forms = document.getElementsByClassName('needs-validation');
        // Loop over them and prevent submission
        var validation = Array.prototype.filter.call(forms, function(form) {
          form.addEventListener('submit', function(event) {
            if (form.checkValidity() === false) {
              event.preventDefault();
              event.stopPropagation();
            }
            form.classList.add('was-validated');
          }, false);
        });
      }, false);      
    })();
    
</script>
@stop